import { get,post } from '@/utils/requset';

//多次调用请求函数，统一处理请求结果
function http(promise) {
    return promise
      .then(res => res)
      .catch(err => {
        console.error('Request failed:', err); // 增加错误日志
        throw err; // 重新抛出错误以便调用者可以捕获并处理
      });
  }

//列表
export function getlist() {
    return http(get('/index.php/index/teacher/teacherlist'));
  }

  //添加
  export function addlist(data) {
    return http(post('/index.php/index/index/addteacher', data));
  }

  //搜索
  export function searchlist(data) {
    return http(post('/index.php/index/teacher/getsearch', data));
  }
  
  //删除
  export function deletelist(id) {
    return http(post('/index.php/index/teacher/delteacher', { id }));
  }

  //修改
  export function updatelist(data) {
    return http(post('/index.php/index/index/upteacher', data));
  }

  